我想在线性混合模型中绘制一些变量的固定效果。
我的数据看起来像这样(帖子末尾的“数据”数据框):
> str(Data)
'data.frame': 155 obs. of 5 variables:
$ y : num 58.6 23 28.4 37.9 33.8 ...
$ x2 : num 44.5 36.6 41.8 44.9 37 ...
$ x1 : num 1.198 0.881 1.059 1.401 0.899 ...
$ ramdn : num 614 614 614 614 614 ...
$ Factor1: Factor w/ 2 levels "0","1": 2 2 2 2 2 2 2 2 2 2 ...
为了线性化某些关系,我将对数应用于某些变量。我还有,模型中的一些虚拟变量。我对这些虚拟变量的影响及其与一些解释变量的相互作用感兴趣。所以我构建了以下模型:
model1 <- lmer(log(y) ~ log(x1) + log(x2)
+ Factor1 + log(x1):Factor1
+ (1 | ramdn),
data = Data, REML=T)
我想绘制x1,Factor1的model1和x1:Factor1 BUT中的效果与之前的变量反向变换。
我尝试使用“effects”包的函数Effect()。包装手册对如何在Effect()函数中使用“转换”选项有一些解释(以处理类似于我的问题)。但是,我不确定如何为我的特定情况编写代码。
问候!
数据:
y x2 x1 ramdn Factor1
1 58.5975 44.4500 1.1984324 613.5333 1
2 22.9575 36.6500 0.8805912 613.5333 1
3 28.4400 41.8000 1.0585538 613.5333 1
4 37.9050 44.8500 1.4006130 613.5333 1
5 33.7950 36.9500 0.8991701 613.5333 1
6 38.1075 37.1000 0.8782735 613.5333 1
7 44.0400 34.2500 0.7048026 613.5333 1
8 55.0275 54.3500 1.7273683 613.5333 1
9 49.3050 42.6500 1.0393807 613.5333 1
10 81.2550 59.2056 2.0948736 613.5333 1
11 62.0850 48.3513 1.5338795 613.5333 1
12 50.1900 41.6500 1.2142345 613.5333 1
13 33.6450 35.2500 0.8337280 613.5333 1
14 39.2175 43.9500 1.7132289 613.6000 1
15 43.1100 47.6000 2.0655231 613.6000 1
16 34.4700 47.9500 1.9432752 613.6000 1
17 51.4650 52.5000 2.3688668 613.6000 1
18 41.0625 45.8000 1.9521565 613.6000 1
19 38.3475 43.6000 1.7753029 613.6000 1
20 33.0900 41.8000 1.5377741 613.6000 1
21 74.3475 58.5000 3.4409113 613.6000 1
22 46.1925 45.4000 1.4750988 613.6667 1
23 42.4350 47.6500 2.0098146 613.6667 1
24 57.8250 48.9000 2.0655091 613.6667 1
25 65.0325 50.4500 2.3190787 613.6667 1
26 30.8250 38.2500 1.0647889 613.6667 1
27 100.4100 56.9000 2.7561874 613.6667 1
28 41.7900 46.7000 1.8323075 613.6667 1
29 54.7275 30.4500 0.7998242 613.6667 1
30 40.7550 32.2000 0.9330968 613.6667 1
31 39.4500 38.3500 1.2283577 613.6667 1
32 47.8800 42.1500 1.3375728 613.7333 1
33 21.8400 35.1500 0.9923962 613.7333 1
34 16.0500 31.2000 0.6087892 613.7333 1
35 40.5450 35.1500 0.8920347 613.7333 1
36 41.9250 42.6000 1.4137085 613.7333 1
37 73.4550 47.2000 1.5752099 613.7333 1
38 17.0700 28.4000 0.5828724 613.7333 1
39 36.7875 36.3500 0.9517135 613.7333 1
40 21.1050 36.1000 0.8375987 613.7333 1
41 14.8950 32.6500 0.6061603 613.7333 1
42 24.2025 39.9000 1.4323764 614.0000 1
43 52.8300 40.9000 1.5358920 614.0000 1
44 65.7300 30.9500 0.9686178 614.0000 1
45 60.1050 39.9000 1.4536427 614.0000 1
46 31.9950 38.5000 1.2873466 614.0000 1
47 49.8450 40.5000 1.4687453 614.0000 1
48 14.6100 28.1000 0.6416651 614.0000 1
49 72.0900 38.6000 1.1688303 614.0000 1
50 20.5275 41.6500 1.3940798 614.0000 1
51 7.9100 34.9000 0.6477430 173.5333 0
52 9.9950 31.0500 0.5899185 173.5333 0
53 19.9350 34.5500 0.6597423 173.5333 0
54 20.6300 35.5000 0.6478895 173.5333 0
55 7.3750 29.6000 0.5137679 173.5333 0
56 32.6800 39.3500 1.0047953 173.5333 0
57 36.0100 46.8000 1.4549304 173.5333 0
58 46.4850 47.0500 1.2191702 173.5333 0
59 20.6600 36.7500 0.8760850 173.5333 0
60 31.4400 57.4550 2.2152639 173.5333 0
61 22.9300 39.5000 1.0542302 173.5333 0
62 33.5250 54.2400 1.8855264 173.5333 0
63 32.0400 44.0000 1.3498571 173.5333 0
64 20.6900 40.0000 1.0532139 173.5333 0
65 27.3650 38.4500 0.9159931 173.5333 0
66 26.3550 44.8000 1.4510899 173.6000 0
67 39.2050 49.9500 1.9629481 173.6000 0
68 10.0800 25.6000 0.5156962 173.6000 0
69 25.6850 38.0000 1.1486014 173.6000 0
70 17.5250 35.9000 1.0771279 173.6000 0
71 28.6600 39.5000 1.3578485 173.6000 0
72 44.9800 52.1000 2.4587256 173.6000 0
73 9.1450 30.5000 0.7515741 173.6000 0
74 36.6150 41.1500 1.1749152 173.6000 0
75 26.7150 41.0500 1.2936095 173.6000 0
76 13.2750 35.7500 0.9389423 173.6000 0
77 8.1850 27.5000 0.5294950 173.6000 0
78 38.0500 48.9500 1.9194800 173.6000 0
79 9.2700 30.5000 0.6529344 173.6000 0
80 30.3100 46.4000 1.6313355 173.6000 0
81 8.4700 27.8500 0.4889965 173.6000 0
82 27.2650 37.3500 1.0358054 173.6000 0
83 12.1200 35.5000 0.9177838 173.6000 0
84 13.3450 34.5000 0.7755596 173.6000 0
85 29.9500 42.7000 1.2190722 173.6000 0
86 65.1300 54.2500 2.2150884 173.6667 0
87 23.3900 45.0500 1.4126866 173.6667 0
88 25.2100 38.7000 0.9831279 173.6667 0
89 23.2250 42.5000 1.3651128 173.6667 0
90 11.2000 34.0000 0.8601449 173.6667 0
91 13.5150 35.5000 0.8793605 173.6667 0
92 13.8850 37.1000 1.0224724 173.6667 0
93 37.8050 46.8500 1.5964718 173.6667 0
94 27.6350 42.7500 1.2646329 173.6667 0
95 6.7950 29.8000 0.5724672 173.6667 0
96 13.9600 37.3500 0.9180422 173.6667 0
97 22.6500 40.5000 1.1448830 173.6667 0
98 11.1000 30.6500 0.6720113 173.6667 0
99 13.5750 29.0000 0.5750469 173.6667 0
100 18.3100 39.8500 1.0456081 173.6667 0
101 34.5600 46.2000 1.5398369 173.6667 0
102 25.2550 45.0000 1.3354013 173.6667 0
103 42.1500 44.7500 1.4946291 173.6667 0
104 19.5900 39.5500 1.0462760 173.6667 0
105 16.7800 41.9500 1.2370549 173.6667 0
106 9.5050 31.3000 0.6696161 173.6667 0
107 13.4950 35.7500 0.8740229 173.6667 0
108 28.9950 41.9500 1.3488790 173.6667 0
109 26.1950 49.0500 1.7442432 173.6667 0
110 25.7350 43.7500 1.4500018 173.6667 0
111 5.4500 30.4500 0.6349793 173.6667 0
112 29.3500 44.2500 1.3385595 173.6667 0
113 6.5350 24.9500 0.3586071 173.7333 0
114 31.5950 40.0000 0.9669847 173.7333 0
115 19.4600 30.1500 0.5479925 173.7333 0
116 20.5800 35.0000 0.7807312 173.7333 0
117 10.9200 32.5500 0.6098463 173.7333 0
118 6.4200 25.1500 0.3420720 173.7333 0
119 31.6050 41.4500 1.0241848 173.7333 0
120 10.8300 29.9500 0.5039027 173.7333 0
121 9.6050 26.0000 0.3882891 173.7333 0
122 19.8800 38.8000 1.0337043 173.7333 0
123 39.9250 45.3500 1.2731606 173.7333 0
124 21.3450 37.3000 0.7884030 173.7333 0
125 11.1350 27.1000 0.4078437 173.7333 0
126 16.9450 35.5000 0.7681240 173.7333 0
127 41.5600 42.3500 1.0675166 173.7333 0
128 5.7400 26.6500 0.4269779 173.7333 0
129 6.9200 24.9000 0.3442184 173.7333 0
130 22.5250 33.5500 0.6849665 173.7333 0
131 29.2200 38.1500 0.9465223 173.7333 0
132 47.4400 49.9000 1.7947956 174.0000 0
133 34.6100 38.2000 0.9341298 174.0000 0
134 9.9800 29.9000 0.5823262 174.0000 0
135 6.1050 23.8500 0.3586040 174.0000 0
136 21.7350 36.2500 0.8220383 174.0000 0
137 15.0850 32.4500 0.7322603 174.0000 0
138 11.1650 34.5000 0.7512544 174.0000 0
139 10.3000 30.9500 0.7076896 174.0000 0
140 27.1100 42.7000 1.3166414 174.0000 0
141 7.8400 30.0500 0.6716206 174.0000 0
142 27.6300 40.6500 1.1142399 174.0000 0
143 18.6200 35.8500 0.9005147 174.0000 0
144 17.8900 38.0500 0.9661885 174.0000 0
145 9.6900 30.2000 0.6374743 174.0000 0
146 18.2500 36.5500 0.9663555 174.0000 0
147 7.9750 27.7000 0.5819161 174.0000 0
148 22.1950 38.8500 1.0921669 174.0000 0
149 31.9150 44.5000 1.4258057 174.0000 0
150 5.7250 28.2500 0.5879370 174.0000 0
151 6.9750 29.1000 0.6399832 174.0000 0
152 36.7550 41.0000 1.2455503 174.0000 0
153 5.5500 27.5000 0.4719748 174.0000 0
154 10.3950 30.5000 0.5763215 174.0000 0
155 21.0600 35.5000 0.8195092 174.0000 0