Linear model from iterative process in R

by Roxanne   Last Updated September 01, 2018 21:19 PM

I would like to test a relationship between tow factors such as birds occurrence and temperature for instance, to test if temperature affects birds occurrence from a country (e.g. Germany).

I have a sample of 200 points from Germany taken randomly.

I extract from those points the temperature and birds occurrence values.

I repeat the sampling of 200 random points 100 times, in a way that I compute 100 iterations of a linear model lm(birds occurrence ~ temperature) -> lm_model.

I choose to proceed by iteration, as 200 points alone are not representative of the entire country, and as spacial auto-correlation issues will pop-up if I take into account all location points from Germany at once. Nb: the aim is to process a linear model removing spatial autocorrelation effect without using a Spatial Autoregression error model (SARerr).

At the end, I have 100 lm_model output, with vectors of 100 p-values, 100 slopes and 100 standard errors values. I would like to extract from those:

• one p-value representative of all 100 p-values generated,
• one slope (=estimate) to know if my relationship is positive or negative,
• one standard error.

Example of code (with birds_list[[i]] a list with 200 birds occurrence values):

for(i in 1:100){
lm_model <- summary(lm(birds_list[[i]]~ temperature_list[[i]]))
lm_estimate[[i]] <- lm_model[[4]][2,1]
lm_std_error[[i]] <- lm_model[[4]][2,2]
lm_pv[[i]]  <- lm_model[[4]][2,4]
}

Concerning the p-value, I used so far the so called 'sum of logarithm' https://www.rdocumentation.org/packages/metap/versions/1.0/topics/sumlog which seems fine, but for the slope and standard error, I am not sure how I can do that... Not sure if taking a mean / median would be correct...

Does the overall approach seem correct? Does anyone would have a suggestion on a way of generating the slope or standard error values?

Many thanks for your help and time !!!

Tags :