简体   繁体   中英

Dropping two values in a dependent variable of a regression in R

If my y value for the regression has four values in the entire data (996, 997, 998, 999), I want to eliminate two values (996 and 999) when regressing on other variables. It is originally a Tobit, but for this sake I need to do a regular OLS regression. If you refer to the picture, essentially, I want to only consider the values that are valid (211). I'm not sure how to do this in R.

在此处输入图片说明

假设您将“ smoke_data”作为数据表,并将“ value”作为响应变量,这是一种排除不必要值的快速方法。

lm(value~.,data=smoke_data[smoke_data[,"value"]!=996 & smoke_data[,"value"]!=999, ])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM