0

I am currently trying to conduct a two-way ANOVA in R using bootstrapping. In the bootstrap function I am writing, I am running into an issue trying to call the coefficients in which to bootstrap. The model I'm dealing with currently is looking at two variables: EtOH treatment (3 levels) and specific axons (4 levels). My current function to view the coefficients is

summary.lm(lm(distance~treatment*axon)

but I get the following table:

Coefficients:
                            Estimate Std. Error t value Pr(>|t|)    
(Intercept)                  1.35893    0.05247  25.901  < 2e-16 ***
treatmentChronic            -0.60041    0.08109  -7.404 1.46e-12 ***
treatmentControl             0.13440    0.07002   1.919   0.0559 .  
axonAxon 2                   0.06613    0.07420   0.891   0.3735    
axonAxon 3                   0.19200    0.07420   2.588   0.0102 *  
axonAxon 4                   0.18240    0.07420   2.458   0.0146 *  
treatmentChronic:axonAxon 2 -0.03650    0.11468  -0.318   0.7505    
treatmentControl:axonAxon 2  0.01220    0.09903   0.123   0.9020    
treatmentChronic:axonAxon 3 -0.08533    0.11468  -0.744   0.4574    
treatmentControl:axonAxon 3 -0.02033    0.09903  -0.205   0.8375    
treatmentChronic:axonAxon 4  0.02501    0.11468   0.218   0.8275    
treatmentControl:axonAxon 4  0.05260    0.09903   0.531   0.5957 

As you can see, Axon 1 and Acute treatment, along with their interactions are missing. Is there anyway to resolve this so that the values may be called and bootstrapped?

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
  • change your model to have an intercept of 0, `lm(distance ~ 0 + treatment*axon)`. Currently the "missing" levels are being estimated in the Intercept. – Nate Oct 09 '16 at 18:43
  • Thank you! All three treatment levels are now being shown, but still only 3 of the axon levels. Is there a way to resolve this with the formula? – Tim Lehmberg Oct 09 '16 at 18:49
  • I don't know right now, if no one else comes to the rescue, I'll double back tomorrow and try to help – Nate Oct 09 '16 at 19:14
  • Please don't use the "Run code snippet" feature for R, it doesn't work. Having said that, this is not reproducible. Please review "How to Ask" and the R tag description. You need to provide a reproducible example that we can run, including data. – Hack-R Oct 09 '16 at 19:32
  • The reason that you don't see one of the levels is that it's the reference level. This is omitted to avoid the dummy variable trap. You can include it if you omit the intercept. This question has been asked before on Stack Overflow. – Hack-R Oct 09 '16 at 19:35
  • @NathanDay thanks very much! – Tim Lehmberg Oct 09 '16 at 21:45
  • @Hack-R Thank you for your comments! I looked over the link which you stated that the question had already been addressed (How (and why) do you use contrasts?) but I'm afraid I'm still a little bit confused. As I said above, removing the intercept only allows me to see the full set of levels for one of the independent variables but not both. Are you aware of anyway in which I would be able to show the full set of levels for both my variables? Thanks again – Tim Lehmberg Oct 10 '16 at 00:41
  • So the work around to get the coef of axon1 is something like this (ps its a little janky). Change `lm(distance~treatment*axon, contrasts = list(axon = contr.sum)` the `contr.sum` is saying make the coefs of axon1:4 sum to 0. This is useful for plotting and other stuff, but in your case you can then do some simple algebra `coef_axon1 = -(sum(coef_axon2, coef_axon3, coef_axon4))`. Sorry I had to hit you with the longest comment in the world, I don't think this was a really deserving of the duplicate closure. Let me know if this works, I'm happy to help :) – Nate Oct 10 '16 at 19:04

0 Answers0