http://www.stata.com/support/faqs/stat/adjust.html指出:
实际上,adjust 只是 predict 的一个前端
它通过为预测创建一个新数据集来工作。
Rpredict
有一个参数newdata
可用于改变预测假设,但可能不像 Stata 那样容易adjust
。transform
可能也很有趣,请参见以下示例。
# create model
mtcars.lm <- lm(hp~disp*cyl,mtcars)
# default fit predictions
predict(mtcars.lm)
Mazda RX4 Mazda RX4 Wag Datsun 710 Hornet 4 Drive
128.60896 128.60896 80.25811 128.88296
Hornet Sportabout Valiant Duster 360 Merc 240D
208.48842 128.79069 208.48842 75.58796
Merc 230 Merc 280 Merc 280C Merc 450SE
76.29995 128.63021 128.63021 197.85671
Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental
197.85671 197.85671 222.63037 221.11516
Chrysler Imperial Fiat 128 Honda Civic Toyota Corolla
218.58981 83.79391 84.15593 84.71104
Toyota Corona Dodge Challenger AMC Javelin Camaro Z28
78.79793 203.18519 201.41745 207.22575
Pontiac Firebird Fiat X1-9 Porsche 914-2 Lotus Europa
213.53912 83.75770 78.77380 81.81483
Ford Pantera L Ferrari Dino Maserati Bora Volvo 142E
207.35202 128.56702 201.03865 78.68933
# predict assuming all cars have 8 cylinders
predict(mtcars.lm,newdata=transform(mtcars,cyl=8))
Mazda RX4 Mazda RX4 Wag Datsun 710 Hornet 4 Drive
183.2349 183.2349 176.6690 195.6091
Hornet Sportabout Valiant Duster 360 Merc 240D
208.4884 191.4423 208.4884 181.5556
Merc 230 Merc 280 Merc 280C Merc 450SE
180.8106 184.1946 184.1946 197.8567
Merc 450SL Merc 450SLC Cadillac Fleetwood Lincoln Continental
197.8567 197.8567 222.6304 221.1152
Chrysler Imperial Fiat 128 Honda Civic Toyota Corolla
218.5898 172.9694 172.5906 172.0098
Toyota Corona Dodge Challenger AMC Javelin Camaro Z28
178.1969 203.1852 201.4174 207.2257
Pontiac Firebird Fiat X1-9 Porsche 914-2 Lotus Europa
213.5391 173.0073 178.2221 175.0402
Ford Pantera L Ferrari Dino Maserati Bora Volvo 142E
207.3520 181.3409 201.0386 178.3105
至于搜索 R 相关主题,您可能会发现以下链接很有用:如何搜索“R”材料?