-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsem.R
63 lines (59 loc) · 1.62 KB
/
sem.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require(lavaan)
data = read.csv(data_file, stringsAsFactors=F)
# Main
m = "sp_richness~bio_1_50
herbaceous_p_perc~bio_1_50
tax_PC1~bio_1_50
pp_perc_resolved~bio_1_50
herbaceous_p_perc~tax_PC1
sp_richness~tax_PC1
pp_perc_resolved~sp_richness
pp_perc_resolved~herbaceous_p_perc
pp_perc_resolved~tax_PC1"
m.fit = sem(m,data=data,std.ov=T)
summary(m.fit,rsq=T, standardized=T, fit.measures=T)
# Climate represented by PC1
m = "sp_richness~clim_PC1
herbaceous_p_perc~clim_PC1
tax_PC1~clim_PC1
pp_perc_resolved~clim_PC1
herbaceous_p_perc~tax_PC1
sp_richness~tax_PC1
pp_perc_resolved~sp_richness
pp_perc_resolved~herbaceous_p_perc
pp_perc_resolved~tax_PC1"
m.fit = sem(m,data=data,std.ov=T)
summary(m.fit,rsq=T, standardized=T, fit.measures=T)
# Climate represented by PC1 and PC2
m = "sp_richness~clim_PC1
herbaceous_p_perc~clim_PC1
tax_PC1~clim_PC1
pp_perc_resolved~clim_PC1
herbaceous_p_perc~tax_PC1
sp_richness~tax_PC1
pp_perc_resolved~sp_richness
pp_perc_resolved~herbaceous_p_perc
pp_perc_resolved~tax_PC1
sp_richness~clim_PC2
herbaceous_p_perc~clim_PC2
tax_PC1~clim_PC2
pp_perc_resolved~clim_PC2"
m.fit = sem(m,data=data,std.ov=T)
summary(m.fit,rsq=T, standardized=T, fit.measures=T)
# Climate represented by BIO1 and BIO15
m = "sp_richness~bio_1_50
herbaceous_p_perc~bio_1_50
tax_PC1~bio_1_50
pp_perc_resolved~bio_1_50
herbaceous_p_perc~tax_PC1
sp_richness~tax_PC1
pp_perc_resolved~sp_richness
pp_perc_resolved~herbaceous_p_perc
pp_perc_resolved~tax_PC1
sp_richness~bio_15_50
herbaceous_p_perc~bio_15_50
tax_PC1~bio_15_50
pp_perc_resolved~bio_15_50
bio_1_50~~bio_15_50"
m.fit = sem(m,data=data,std.ov=T)
summary(m.fit,rsq=T, standardized=T, fit.measures=T)