我正在预测印度一个地理区域的月平均降水量(Assam和Meghalaya分区)。为此,我使用月平均气温数据和月平均相对湿度数据(我从NOAA网站上这个地理区域的netCDF4文件中提取并在空间上平均)作为自变量(预测因子)。
为了预测的目的,我想建立一个线性回归模型,以降水量作为因变量,以“气温”和“相对湿度”数据作为自变量,使它们在回归过程中具有时间滞后效应。
线性回归方程应如下所示:
这里,"Y“表示降水,"X”表示气温,"Z“表示相对湿度。
“培训数据”样本如下:
ID Time Precipitation Air_Temperature Re
具体来说,我得到了一个错误
错误:变量'poly(x,度数= i,raw = TRUE)‘被拟合为“nMatx.2”类型,但提供了“nMatx.5”类型
我的教授给我提供了这个起始代码:
f = function(x) {
return(x**2)
}
#Set a terribly boring seed for reproducibility
set.seed(1234)
#Make our training data
N = 100
x = sort(runif(N, 0, 1))
y = f(x) + rnorm(N, mean=0, sd=.3)
data_t
我正在运行一个基本的回归: df = pd.DataFrame(playerdata, columns = cols_of_interest)
target = pd.DataFrame(playerdata, columns = ['mins'])
X = df[cols_of_interest]
y = target["mins"]
# Fit and make the predictions by the model
model = sm.OLS(y, X).fit()
predictions = model.predict(X) model.pa