obtain modified response values with the variation removed from conditioned variable in a partial redundancy analysis in r

To obtain modified response values with the variation removed from the conditioned variable in a partial redundancy analysis (PRA) in R, you can use the predict() function on the PRA model object, specifying type = "response" and remove.conditioned = TRUE. The predict() function creates predicted values for the response variable based on the values of the explanatory variables after removing the variation due to the conditioned variable.

Here's an example code snippet:

main.r
library(dismo)
data(BIOMOD_Formate)
pra_model <- pra(weight ~ bio1 + bio2 + bio3 + bio4 + bio5 + bio6 + bio7 + bio8 + bio9, data = BIOMOD_Formate, conditioned = BIOMOD_Formate$alt)
pra_predict <- predict(pra_model, newdata = BIOMOD_Formate, type = "response", remove.conditioned = TRUE)
head(pra_predict)
305 chars
6 lines

In this example, we are using the pra() function from the dismo package to build a PRA model on the BIOMOD_Formate dataset. The dependent variable is weight, and the independent variables are nine bioclimatic variables represented by bio1 through bio9. The conditioned variable is alt.

We then use the predict() function to create predicted values for the response variable weight. The newdata argument specifies that the model should use the original dataset, but we could also use a new dataset with different values for the explanatory variables. The type argument specifies that we want response values, and remove.conditioned argument is set to TRUE, to remove the variation due to the conditioned variable.

The resulting pra_predict object contains the modified response values with the variation due to the conditioned variable removed.

gistlibby LogSnag