lfex2.m 1.0 KB

1234567891011121314151617181920212223242526
  1. % Model the success probability of successive trials of a monkey
  2. % performing a task.
  3. %
  4. % The 'y' variable is a vector of 0/1, with 1 denoting success on
  5. % the trial; 0 failure. The fitting procedure uses logistic
  6. % regression within sliding windows (specified by the 'family','binomial'
  7. % arguments).
  8. %
  9. % Choosing the bandwidth here is critical. The data shows `on/off' behavior,
  10. % exhibiting periods of mainly successes, and mainly failures, respectively.
  11. % Large values of alpha will smooth out this behavior, while small values
  12. % will be too sensitive to random variability. Values of 0.15 to 0.2 seem
  13. % reasonable for this example.
  14. %
  15. % AIC is based on asymptotic approximations, and seems unreliable here --
  16. % formal model selection needs more investigation.
  17. %
  18. % Data is from Keith Purpura.
  19. load 050527_correct.mat;
  20. y = byTrial(1).correct';
  21. n = length(y);
  22. fit = locfit((1:n)',y,'family','binomial','alpha',0.15);
  23. lfplot(fit);
  24. title('Local Logistic Regression - Estimating Success Probability');
  25. lfband(fit);