Predict Method for an 'lm_betaselect' Object
Source:R/lm_betaselect_methods.R
predict.lm_betaselect.Rd
Compute the predicted
values in a model fitted by
lm_betaselect()
.
Arguments
- object
An
lm_betaselect
-class object.- model_type
The model from which the the predicted values are computed. For
"beta"
or"standardized"
, the model is the one after selected variables standardized. For"raw"
or"unstandardized"
, the model is the one before standardization was done.- newdata
If set to a data frame, the predicted values are computed using this data frame. The data must be unstandardized. That is, the variables are of the same units as in the data frame used in
lm_betaselect()
. Ifmodel_type
is"beta"
or"standardized"
, it will be standardized using the setting ofto_standardize
whenobject
is created inlm_betaselect()
.- ...
Arguments to be passed to
stats::predict.lm()
. Please refer to the help page ofstats::predict.lm()
.
Value
It returns the output of stats::predict.lm()
.
Details
It simply passes the model before
or after selected variables
are standardized to the
predict
-method of an lm
object.
Author
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448
Examples
data(data_test_mod_cat)
lm_beta_x <- lm_betaselect(dv ~ iv*mod + cov1 + cat1,
data = data_test_mod_cat,
to_standardize = "iv")
predict(lm_beta_x)
#> 1 2 3 4 5 6 7 8
#> 6421.680 6530.429 6487.252 6107.743 6284.481 5153.358 6662.658 7827.410
#> 9 10 11 12 13 14 15 16
#> 7029.198 8156.635 6019.411 5574.344 6180.277 7010.803 4963.590 6059.476
#> 17 18 19 20 21 22 23 24
#> 7239.020 6698.976 6764.336 5353.118 7577.253 7719.758 6576.826 8237.401
#> 25 26 27 28 29 30 31 32
#> 8200.935 7931.369 6569.994 6882.033 8267.304 7128.476 5959.531 6920.342
#> 33 34 35 36 37 38 39 40
#> 5887.038 6007.579 5586.136 6880.800 5452.636 7665.795 6564.230 6089.381
#> 41 42 43 44 45 46 47 48
#> 7046.119 5101.476 6404.048 6188.349 6429.859 7628.757 7847.636 6881.857
#> 49 50 51 52 53 54 55 56
#> 6592.794 7275.835 6087.745 6132.776 6378.544 6454.268 5449.982 7631.170
#> 57 58 59 60 61 62 63 64
#> 6713.771 6819.890 7710.031 6261.576 5468.773 5283.316 6904.287 5694.848
#> 65 66 67 68 69 70 71 72
#> 5338.961 7166.193 6417.537 6584.919 5788.587 7106.867 6478.441 4945.244
#> 73 74 75 76 77 78 79 80
#> 4720.702 5969.793 6776.512 6825.743 6467.491 5401.580 5291.916 6058.456
#> 81 82 83 84 85 86 87 88
#> 5960.974 5662.433 7254.471 7000.237 7692.378 5039.460 6057.840 6331.362
#> 89 90 91 92 93 94 95 96
#> 6532.205 5538.184 5749.854 7334.872 6434.210 6442.079 5618.349 7410.285
#> 97 98 99 100 101 102 103 104
#> 5891.992 6688.047 7174.997 5234.916 5729.762 7843.111 6855.171 6811.118
#> 105 106 107 108 109 110 111 112
#> 5805.968 6535.212 5729.227 6194.901 5697.342 7666.604 6222.894 6451.290
#> 113 114 115 116 117 118 119 120
#> 7328.785 7098.303 6081.005 6725.354 6567.422 6935.756 6410.174 7128.479
#> 121 122 123 124 125 126 127 128
#> 6715.371 6660.228 5197.764 6106.589 7344.590 7526.230 6279.533 5559.357
#> 129 130 131 132 133 134 135 136
#> 7033.286 6542.692 7144.951 7685.140 6446.983 6501.323 7291.124 6796.924
#> 137 138 139 140 141 142 143 144
#> 7385.154 8119.350 5659.128 5534.587 7661.700 7252.737 5721.102 5441.864
#> 145 146 147 148 149 150 151 152
#> 6767.296 5303.049 7127.611 5868.182 6265.856 7428.265 5928.060 6519.315
#> 153 154 155 156 157 158 159 160
#> 6212.102 6619.222 6161.753 6646.573 6267.180 5697.635 7634.741 7476.451
#> 161 162 163 164 165 166 167 168
#> 6368.692 7718.742 6548.494 7614.872 7199.461 6022.501 6292.890 7695.434
#> 169 170 171 172 173 174 175 176
#> 7391.428 6960.239 6813.179 7781.359 6785.648 7620.418 6547.261 6510.296
#> 177 178 179 180 181 182 183 184
#> 6435.727 6062.403 7265.656 5537.013 5569.140 5759.934 5044.076 7994.875
#> 185 186 187 188 189 190 191 192
#> 5238.464 7685.679 6051.276 4877.087 6937.267 7232.846 6657.324 5865.098
#> 193 194 195 196 197 198 199 200
#> 5689.028 6284.553 6422.299 6848.322 8412.144 5953.606 5330.208 6794.527
#> 201 202 203 204 205 206 207 208
#> 6125.811 6001.644 6578.588 6495.348 5966.723 7775.976 4944.345 5885.834
#> 209 210 211 212 213 214 215 216
#> 7648.779 5357.603 6869.724 6066.624 6030.433 7593.993 7683.360 7457.460
#> 217 218 219 220 221 222 223 224
#> 5868.477 7586.109 7170.624 6687.964 5437.511 6393.324 6109.968 5763.697
#> 225 226 227 228 229 230 231 232
#> 8206.366 5924.408 6295.905 5746.729 5995.474 7565.798 7136.765 7477.150
#> 233 234 235 236 237 238 239 240
#> 8362.617 6904.169 6184.111 7320.046 5929.559 5632.414 6441.408 6765.401
#> 241 242 243 244 245 246 247 248
#> 5889.105 7862.103 6099.654 4991.337 6841.235 7193.836 6544.202 5532.230
#> 249 250 251 252 253 254 255 256
#> 7048.373 5667.930 5574.095 7211.219 6317.915 6521.687 7126.394 5619.901
#> 257 258 259 260 261 262 263 264
#> 6035.829 5399.919 5788.256 7449.717 4060.268 6318.630 5604.818 8676.259
#> 265 266 267 268 269 270 271 272
#> 6302.037 4934.697 6786.365 6876.233 6826.034 5631.543 7322.045 7413.243
#> 273 274 275 276 277 278 279 280
#> 5908.308 7019.507 6412.924 8025.616 6798.272 7587.134 7390.018 7090.875
#> 281 282 283 284 285 286 287 288
#> 7157.391 5334.951 5626.114 6540.264 7904.521 6717.025 6528.334 4869.434
#> 289 290 291 292 293 294 295 296
#> 5814.451 5573.749 6389.860 6575.074 5782.319 7572.580 5881.327 5919.935
#> 297 298 299 300 301 302 303 304
#> 6487.915 6136.456 6568.070 6922.463 8126.692 6806.425 8275.516 6029.596
#> 305 306 307 308 309 310 311 312
#> 6301.706 7270.884 5913.753 8218.546 6725.495 5826.919 5299.917 6984.101
#> 313 314 315 316 317 318 319 320
#> 6931.458 7184.770 5799.327 5533.412 6236.289 5136.554 7434.008 6420.101
#> 321 322 323 324 325 326 327 328
#> 8552.462 5930.935 6086.786 6241.706 7713.042 6793.976 5456.381 6108.054
#> 329 330 331 332 333 334 335 336
#> 6699.341 5963.251 7516.234 5827.800 7132.718 6369.051 7277.840 6315.533
#> 337 338 339 340 341 342 343 344
#> 7098.126 6827.736 7213.580 7255.797 6293.986 6472.462 6062.911 7218.634
#> 345 346 347 348 349 350 351 352
#> 6052.513 5240.996 6712.572 7926.542 7083.821 6124.678 7976.134 6668.810
#> 353 354 355 356 357 358 359 360
#> 7552.130 7848.743 7133.763 9020.163 5908.280 6626.493 6319.336 6948.762
#> 361 362 363 364 365 366 367 368
#> 7078.781 6995.973 6159.789 6675.732 7896.857 8560.822 6594.962 5359.732
#> 369 370 371 372 373 374 375 376
#> 5783.347 5743.286 6177.017 5877.047 6465.341 6166.324 6625.031 5166.195
#> 377 378 379 380 381 382 383 384
#> 5824.943 6956.254 6849.930 7455.865 7243.500 6295.138 7592.910 6616.748
#> 385 386 387 388 389 390 391 392
#> 5682.624 7245.582 6006.397 8471.902 6997.524 5374.284 7173.292 6775.784
#> 393 394 395 396 397 398 399 400
#> 6637.279 8399.570 6992.324 6014.283 6989.581 6563.432 6744.687 6832.647
#> 401 402 403 404 405 406 407 408
#> 7358.311 6817.467 7658.621 7688.747 7440.909 7909.164 5871.422 8839.278
#> 409 410 411 412 413 414 415 416
#> 6035.326 6353.896 5808.010 8124.111 5941.151 7053.657 6855.814 6185.920
#> 417 418 419 420 421 422 423 424
#> 7051.917 6129.481 6955.991 6836.320 5934.141 7242.391 6809.946 6087.901
#> 425 426 427 428 429 430 431 432
#> 5476.632 6657.740 7508.467 7582.255 6254.440 6962.778 6563.426 6863.976
#> 433 434 435 436 437 438 439 440
#> 6787.891 7246.169 8053.271 6415.865 7353.807 6995.639 6991.630 6257.776
#> 441 442 443 444 445 446 447 448
#> 8767.427 6578.275 5053.169 6722.696 6067.139 6102.534 6096.265 7631.003
#> 449 450 451 452 453 454 455 456
#> 5158.090 7813.609 6204.944 5419.874 6060.528 6749.025 5475.222 5966.580
#> 457 458 459 460 461 462 463 464
#> 7924.950 6682.756 6170.653 8090.692 5766.812 7326.426 5729.922 5988.583
#> 465 466 467 468 469 470 471 472
#> 5528.841 6270.466 7375.933 6021.984 6359.143 6046.785 6968.952 6910.191
#> 473 474 475 476 477 478 479 480
#> 8053.836 7046.044 6049.573 7556.126 6732.662 7747.697 8133.011 7220.327
#> 481 482 483 484 485 486 487 488
#> 6902.956 5611.027 7205.584 6708.607 6564.488 5276.263 6527.790 5793.178
#> 489 490 491 492 493 494 495 496
#> 5395.177 8686.422 7248.430 7634.542 6985.081 5619.762 5407.764 6601.611
#> 497 498 499 500
#> 6568.168 6719.200 6607.351 6555.875
predict(lm_beta_x, model_type = "raw")
#> 1 2 3 4 5 6 7 8
#> 6421.680 6530.429 6487.252 6107.743 6284.481 5153.358 6662.658 7827.410
#> 9 10 11 12 13 14 15 16
#> 7029.198 8156.635 6019.411 5574.344 6180.277 7010.803 4963.590 6059.476
#> 17 18 19 20 21 22 23 24
#> 7239.020 6698.976 6764.336 5353.118 7577.253 7719.758 6576.826 8237.401
#> 25 26 27 28 29 30 31 32
#> 8200.935 7931.369 6569.994 6882.033 8267.304 7128.476 5959.531 6920.342
#> 33 34 35 36 37 38 39 40
#> 5887.038 6007.579 5586.136 6880.800 5452.636 7665.795 6564.230 6089.381
#> 41 42 43 44 45 46 47 48
#> 7046.119 5101.476 6404.048 6188.349 6429.859 7628.757 7847.636 6881.857
#> 49 50 51 52 53 54 55 56
#> 6592.794 7275.835 6087.745 6132.776 6378.544 6454.268 5449.982 7631.170
#> 57 58 59 60 61 62 63 64
#> 6713.771 6819.890 7710.031 6261.576 5468.773 5283.316 6904.287 5694.848
#> 65 66 67 68 69 70 71 72
#> 5338.961 7166.193 6417.537 6584.919 5788.587 7106.867 6478.441 4945.244
#> 73 74 75 76 77 78 79 80
#> 4720.702 5969.793 6776.512 6825.743 6467.491 5401.580 5291.916 6058.456
#> 81 82 83 84 85 86 87 88
#> 5960.974 5662.433 7254.471 7000.237 7692.378 5039.460 6057.840 6331.362
#> 89 90 91 92 93 94 95 96
#> 6532.205 5538.184 5749.854 7334.872 6434.210 6442.079 5618.349 7410.285
#> 97 98 99 100 101 102 103 104
#> 5891.992 6688.047 7174.997 5234.916 5729.762 7843.111 6855.171 6811.118
#> 105 106 107 108 109 110 111 112
#> 5805.968 6535.212 5729.227 6194.901 5697.342 7666.604 6222.894 6451.290
#> 113 114 115 116 117 118 119 120
#> 7328.785 7098.303 6081.005 6725.354 6567.422 6935.756 6410.174 7128.479
#> 121 122 123 124 125 126 127 128
#> 6715.371 6660.228 5197.764 6106.589 7344.590 7526.230 6279.533 5559.357
#> 129 130 131 132 133 134 135 136
#> 7033.286 6542.692 7144.951 7685.140 6446.983 6501.323 7291.124 6796.924
#> 137 138 139 140 141 142 143 144
#> 7385.154 8119.350 5659.128 5534.587 7661.700 7252.737 5721.102 5441.864
#> 145 146 147 148 149 150 151 152
#> 6767.296 5303.049 7127.611 5868.182 6265.856 7428.265 5928.060 6519.315
#> 153 154 155 156 157 158 159 160
#> 6212.102 6619.222 6161.753 6646.573 6267.180 5697.635 7634.741 7476.451
#> 161 162 163 164 165 166 167 168
#> 6368.692 7718.742 6548.494 7614.872 7199.461 6022.501 6292.890 7695.434
#> 169 170 171 172 173 174 175 176
#> 7391.428 6960.239 6813.179 7781.359 6785.648 7620.418 6547.261 6510.296
#> 177 178 179 180 181 182 183 184
#> 6435.727 6062.403 7265.656 5537.013 5569.140 5759.934 5044.076 7994.875
#> 185 186 187 188 189 190 191 192
#> 5238.464 7685.679 6051.276 4877.087 6937.267 7232.846 6657.324 5865.098
#> 193 194 195 196 197 198 199 200
#> 5689.028 6284.553 6422.299 6848.322 8412.144 5953.606 5330.208 6794.527
#> 201 202 203 204 205 206 207 208
#> 6125.811 6001.644 6578.588 6495.348 5966.723 7775.976 4944.345 5885.834
#> 209 210 211 212 213 214 215 216
#> 7648.779 5357.603 6869.724 6066.624 6030.433 7593.993 7683.360 7457.460
#> 217 218 219 220 221 222 223 224
#> 5868.477 7586.109 7170.624 6687.964 5437.511 6393.324 6109.968 5763.697
#> 225 226 227 228 229 230 231 232
#> 8206.366 5924.408 6295.905 5746.729 5995.474 7565.798 7136.765 7477.150
#> 233 234 235 236 237 238 239 240
#> 8362.617 6904.169 6184.111 7320.046 5929.559 5632.414 6441.408 6765.401
#> 241 242 243 244 245 246 247 248
#> 5889.105 7862.103 6099.654 4991.337 6841.235 7193.836 6544.202 5532.230
#> 249 250 251 252 253 254 255 256
#> 7048.373 5667.930 5574.095 7211.219 6317.915 6521.687 7126.394 5619.901
#> 257 258 259 260 261 262 263 264
#> 6035.829 5399.919 5788.256 7449.717 4060.268 6318.630 5604.818 8676.259
#> 265 266 267 268 269 270 271 272
#> 6302.037 4934.697 6786.365 6876.233 6826.034 5631.543 7322.045 7413.243
#> 273 274 275 276 277 278 279 280
#> 5908.308 7019.507 6412.924 8025.616 6798.272 7587.134 7390.018 7090.875
#> 281 282 283 284 285 286 287 288
#> 7157.391 5334.951 5626.114 6540.264 7904.521 6717.025 6528.334 4869.434
#> 289 290 291 292 293 294 295 296
#> 5814.451 5573.749 6389.860 6575.074 5782.319 7572.580 5881.327 5919.935
#> 297 298 299 300 301 302 303 304
#> 6487.915 6136.456 6568.070 6922.463 8126.692 6806.425 8275.516 6029.596
#> 305 306 307 308 309 310 311 312
#> 6301.706 7270.884 5913.753 8218.546 6725.495 5826.919 5299.917 6984.101
#> 313 314 315 316 317 318 319 320
#> 6931.458 7184.770 5799.327 5533.412 6236.289 5136.554 7434.008 6420.101
#> 321 322 323 324 325 326 327 328
#> 8552.462 5930.935 6086.786 6241.706 7713.042 6793.976 5456.381 6108.054
#> 329 330 331 332 333 334 335 336
#> 6699.341 5963.251 7516.234 5827.800 7132.718 6369.051 7277.840 6315.533
#> 337 338 339 340 341 342 343 344
#> 7098.126 6827.736 7213.580 7255.797 6293.986 6472.462 6062.911 7218.634
#> 345 346 347 348 349 350 351 352
#> 6052.513 5240.996 6712.572 7926.542 7083.821 6124.678 7976.134 6668.810
#> 353 354 355 356 357 358 359 360
#> 7552.130 7848.743 7133.763 9020.163 5908.280 6626.493 6319.336 6948.762
#> 361 362 363 364 365 366 367 368
#> 7078.781 6995.973 6159.789 6675.732 7896.857 8560.822 6594.962 5359.732
#> 369 370 371 372 373 374 375 376
#> 5783.347 5743.286 6177.017 5877.047 6465.341 6166.324 6625.031 5166.195
#> 377 378 379 380 381 382 383 384
#> 5824.943 6956.254 6849.930 7455.865 7243.500 6295.138 7592.910 6616.748
#> 385 386 387 388 389 390 391 392
#> 5682.624 7245.582 6006.397 8471.902 6997.524 5374.284 7173.292 6775.784
#> 393 394 395 396 397 398 399 400
#> 6637.279 8399.570 6992.324 6014.283 6989.581 6563.432 6744.687 6832.647
#> 401 402 403 404 405 406 407 408
#> 7358.311 6817.467 7658.621 7688.747 7440.909 7909.164 5871.422 8839.278
#> 409 410 411 412 413 414 415 416
#> 6035.326 6353.896 5808.010 8124.111 5941.151 7053.657 6855.814 6185.920
#> 417 418 419 420 421 422 423 424
#> 7051.917 6129.481 6955.991 6836.320 5934.141 7242.391 6809.946 6087.901
#> 425 426 427 428 429 430 431 432
#> 5476.632 6657.740 7508.467 7582.255 6254.440 6962.778 6563.426 6863.976
#> 433 434 435 436 437 438 439 440
#> 6787.891 7246.169 8053.271 6415.865 7353.807 6995.639 6991.630 6257.776
#> 441 442 443 444 445 446 447 448
#> 8767.427 6578.275 5053.169 6722.696 6067.139 6102.534 6096.265 7631.003
#> 449 450 451 452 453 454 455 456
#> 5158.090 7813.609 6204.944 5419.874 6060.528 6749.025 5475.222 5966.580
#> 457 458 459 460 461 462 463 464
#> 7924.950 6682.756 6170.653 8090.692 5766.812 7326.426 5729.922 5988.583
#> 465 466 467 468 469 470 471 472
#> 5528.841 6270.466 7375.933 6021.984 6359.143 6046.785 6968.952 6910.191
#> 473 474 475 476 477 478 479 480
#> 8053.836 7046.044 6049.573 7556.126 6732.662 7747.697 8133.011 7220.327
#> 481 482 483 484 485 486 487 488
#> 6902.956 5611.027 7205.584 6708.607 6564.488 5276.263 6527.790 5793.178
#> 489 490 491 492 493 494 495 496
#> 5395.177 8686.422 7248.430 7634.542 6985.081 5619.762 5407.764 6601.611
#> 497 498 499 500
#> 6568.168 6719.200 6607.351 6555.875