1

I'm trying to recreate Leo Breiman's work http://www.stat.washington.edu/courses/stat527/s13/readings/BreimanSpector_1992.pdf and I'm experiencing some major difficulties in R.

I've made it that far that I have a function producing random samples from multivariate normal distribution with zero mu vector and covariance matrix same as in the paper.

If I understand the paper correctly, I should make a random sample (checked), apply one of the 4 models H1-H4 to get the real values y (checked) and then apply LOOCV, K Fold, or Bootstrap to fit the data and compare the hat ys with the real ones. Though I'm not very experienced, I think I'm capable to construct all of this.

What I'm having major difficulties with is that I can't seem to find any fuction that would allow me to repeat the process in the paragraph above, store the result, and then repeat it again with -1 variables (the excluded variable can be excluded based on any criteria).

I've experimented with step(), stepAIC(), leaps(), regsubsets() and nothing gave me the slightest hint of what I need. However, there's a 100% chance I'm using them wrong. Can you please advise?

Thanks to everyone. Ondra

1 Answers1

0

It's not clear what you mean by "store the result". Which result do you wish to store?

As far as refitting, R has a function update that will refit a model with changed inputs.

Alternatively you might looking for functions like drop1 (and add1).

Functions like leaps are designed to make their own way through many models, you seem to want to implement the individual stages of moving between adjacent models, and refitting.

Glen_b
  • 257,508
  • 32
  • 553
  • 939
  • Well, I'd like to fit the model with let's say 40 variables, calculate Model Error, save the Model Error, drop the least significant explanatory variable, repeat. – Ondra Lepša Sep 16 '14 at 05:36
  • I should take this chance to mention the repeated warnings here on CrossValidated against stepwise model selection. – Glen_b Sep 16 '14 at 06:59
  • See [here](http://stats.stackexchange.com/questions/97257/stepwise-regression-in-r-critical-p-value) for a discussion of how to make `step` work on single-variable-at-a-time significance. See [here](http://stats.stackexchange.com/a/20856/805) for a list of problems with what you want to do. – Glen_b Sep 16 '14 at 07:09
  • 1
    About the stepwise, I know, I've stumbled upon a couple of threads mentioning this; however, I'm struggling with basics. Once I get the model working, I might start experiencing with other methods as well. Now I just need any seemingly justifiable variable deletion technique to get the whole thing going. Nevertheless, I want to thank you for your help :) – Ondra Lepša Sep 16 '14 at 17:29
  • I'm happy to help you learn how to do it. What remains unanswered? – Glen_b Sep 16 '14 at 21:08
  • not sure:) right now im using: 'a – Ondra Lepša Sep 17 '14 at 21:56
  • If you're looping a known number of times I don't see why it would matter which you used. – Glen_b Sep 17 '14 at 22:37
  • However, why not make step larger and use `keep`? – Glen_b Sep 17 '14 at 22:42
  • Is keep a part of some package? it's hard to google "keep" :( Nevertheless, this is how far I've got (and it's not working the way I intended): 'ia[i+1]){ i – Ondra Lepša Sep 20 '14 at 21:37
  • Tried the same with **for** and I might be missing something crucial. i – Ondra Lepša Sep 20 '14 at 21:52
  • Ondra, read the help on `step` of which `keep` is an argument. – Glen_b Sep 21 '14 at 00:21
  • Questions of the form "how do I make this code work" are a better fit for stackoverflow. You need to read the help on `for` (`?"for"` - don't leave out the quotes). I believe `step` will do the whole thing in one go. – Glen_b Sep 21 '14 at 00:35