Back to the main page.

# Bug 504 - cfg.method='glm' in help ft_freq/timelock/sourcestatistics

Status | CLOSED FIXED |

Reported | 2011-02-24 00:25:00 +0100 |

Modified | 2011-06-22 14:19:19 +0200 |

Product: | FieldTrip |

Component: | documentation |

Version: | unspecified |

Hardware: | Macintosh |

Operating System: | Mac OS |

Importance: | P1 normal |

Assigned to: | Jan-Mathijs Schoffelen |

URL: | |

Tags: | |

Depends on: | |

Blocks: | |

See also: |

## Matt Mollison - 2011-02-24 00:25:14 +0100

I'm using ft-20110223 I'm interested in why the ft_freqstatistics, ft_timelockstatistics, and ft_sourcestatistics mention 'glm' as an option for cfg.method, but there is no statistics_glm function like there is for statistics_montecarlo, statistics_analytic, and statistics_stats, which are the other 3 stats methods mentioned in the documentation. Does glm have yet to be added, or is it an artifact of days gone by? If it is going to be implemented, does that mean we could use contrast codes in the design matrix?

## Jan-Mathijs Schoffelen - 2011-02-24 08:15:04 +0100

Hi Matt, this function has existed at some point in a very rudimentary form, but somehow got lost. The documentation unfortunately has not sufficiently been cleaned up. In principle however it is possible to apply GLMs to your data by implementing this in an appropriate statfun_glm. Rather than specifying cfg.method = 'glm', one could specify cfg.method = 'analytic'/'montecarlo' etc, and specify cfg.statistic = 'glm'. As a matter of fact, I even happen to have written such a function, but I don't trust my insights into the GLM enough to throw this code at the rest of the world. Indeed my implementation of the glm allows for contrast codes to be used.

## Robert Oostenveld - 2011-02-24 08:54:07 +0100

Created attachment 25 missing function

## Robert Oostenveld - 2011-02-24 08:55:37 +0100

Hi Matt, Please find the missing function attached to the bugzilla page. It was written by Markus Bauer. To get it to work, you will probably have to make some changes to have it use the ft_prefixed style helper functions.

## Matt Mollison - 2011-02-24 15:56:27 +0100

Hi JM and Robert, Thanks for your quick replies. I am looking through the statistics_glm function that Robert posted, and will try it out. JM, would you be opposed to my pair of eyes checking out your statfun_glm? I'd be interested in combining a GLM-based test with cfg.method = 'analytic' or ''montecarlo', and even if I didn't use it directly your function could definitely serve as a learning tool. Thanks, Matt

## Jan-Mathijs Schoffelen - 2011-06-21 15:12:01 +0200

Hi Matt, Are you still interested in looking at my GLM-code?

## Matt Mollison - 2011-06-21 16:26:23 +0200

Hi JM, Thanks for asking. Yes, I am still interested. That would be great if you could send or attach it. Matt (In reply to comment #5) > Hi Matt, > > Are you still interested in looking at my GLM-code?

## Jan-Mathijs Schoffelen - 2011-06-21 16:35:16 +0200

Created attachment 76 statfun_glm statfun_glm function

## Jan-Mathijs Schoffelen - 2011-06-21 16:39:03 +0200

OK, here it is. Note that the code is highly experimental. What you need to specify prior to calling ft_freqstatistics / ft_timelockstatistics is the following: cfg.statistic = 'glm'; cfg.glm.statistic = 'T' 'beta' or 'R' (T-statistic, beta-weight, or Residuals) cfg.glm.contrast = vector specifying the linear contrast between regressors, should have length N, where N is the number of regressors in your design matrix cfg.design = design matrix NxM = number of regressors times number of observations The function is designed to treat each trial as an observation. I'll let you play with it, and change the status of this bug to fixed (because essentially it's a bug no more...)