[R] mvpart analyses with covariables
Gavin Simpson
gavin.simpson at ucl.ac.uk
Tue Sep 13 11:31:03 CEST 2011
On Tue, 2011-09-13 at 13:46 +0800, 'Ben Ford' wrote:
> Hi all,
>
> I am fairly new to R and I am trying to run mvpart and create a MRT using
> explanatory variables and covariables. I've been following the procedures in
> Numerical Ecoogy with R.
>
> The command (no covariables) which works fine -
>
> ABUNDTMRT <- mvpart(abundance ~
> .,factors,margin=0.08,cp=0,xv="1se",xval=nrow(abundance),xvmult=100,which=4)
>
> where abundance is 4th root transformed fish abundance (103 species x 168
> samples), and factors is the relief (high, medium, low profile, sand
> inundated reef, flat), benthos (coral, sessile inverts, kelp, macroalgae,
> seagrass, sand), depth (continuous in meters), latitude, and longitude of
> each sample.
>
> To try and incorporate spatial autocorrelation (as a covariate) into this I
> have been trying the command -
>
> ABUNDTMRT <- mvpart(abundance ~ environ + spatial,
> data.frame,margin=0.08,cp=0,xv="1se",xval=nrow(abundance),xvmult=100,which=4)
I really don't think you can do that, and even if you could it is not a
good thing to do.
Arrange your variables (explanatory or covariables) into a single data
frame, then, if this data frame contains only variable that go into the
model (explanatory or covariables), you can use the `.` notation:
ABUNDTMRT <- mvpart(abundance ~ ., data = my.data.frame, ...)
However, if you are using covariable in the sense of Canoco, then I
think you are out of luck. There isn't a way to partial out the spatial
effects and fit a model using the non-spatial components of the
environmental/explanatory variables.
I wonder where you got the impression that this could be done?
Of course, you can do this (sort of) if you are prepared to do a bit of
work; i) ordinate the abundance data with spatial covariables as
constraints and take the residuals (all site scores in unconstrained
axes), ii) do the the same thing with the environment so that you
residualise the explanatory variables, iii) take the residualised
species data and the residualised explanatory matrix and use them as
inputs to mvpart(). There may be infelicities here if you need to use
different ordination techniques to residualise the species and the
explanatory variables matrices...
HTH
G
> where abundance is as above, environ is the environmental factors (from
> above) and spatial is the eigenfunctions from a PCNM analysis. data.frame is
> the environ and spatial factors as a data.frame.
>
> This gives the error -
>
> "Error in `[[<-.data.frame`(`*tmp*`, preds, value = c(72L, 72L, 80L, 72L,
> :
> replacement has 504 rows, data has 168"
>
> As I am new to this, I am not sure if I am entering an incorrect formula
> when trying to include the covariables, or if this is just something which
> mvpart cannot do.
>
> Thanks.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list