具有Julia误差的线性模型

具有Julia误差的线性模型,julia,atom-editor,Julia,Atom Editor,我和Julia一起运行线性模型,但我不知道为什么它有错误 为了估计线性模型,您可以使用lm函数(您的代码实际上会覆盖此名称),因此最好编写: using RDatasets using GLM housing = dataset("Ecdat", "Housing") plot(housing, x="LotSize", y="Price", Geom.point) log_housing = DataFrame(LotSize=log(housing[:,2]), Price=log

我和Julia一起运行线性模型,但我不知道为什么它有错误

为了估计线性模型,您可以使用
lm
函数(您的代码实际上会覆盖此名称),因此最好编写:

 using RDatasets
 using GLM
 housing = dataset("Ecdat", "Housing")
 plot(housing, x="LotSize", y="Price", Geom.point)
 log_housing = DataFrame(LotSize=log(housing[:,2]), Price=log(housing[:,1]))
 plot(log_housing, x="LotSize", y="Price", 
 Geom.point,Guide.xlabel("LotSize(log)"), Guide.ylabel("Price(log)"))
 lm = fit(LinearModel, Price ~ LotSize, log_housing)
 #UndefVarError: Price not defined

请包括您的代码和错误作为文本,以及更详细的说明。你看过GLM.jl最近的文档了吗?我上传了代码,现在我会查看GLM.jl。
julia> lm_model = lm(@formula(Price ~ LotSize), log_housing)
StatsModels.DataFrameRegressionModel{GLM.LinearModel{GLM.LmResp{Array{Float64,1}},GLM.DensePredChol{Float64,Base.LinAlg.Cholesky{Float64,Array{Float64,2}}}},Array{Float64,2}}

Formula: Price ~ 1 + LotSize

Coefficients:
             Estimate Std.Error t value Pr(>|t|)
(Intercept)   6.46853  0.276741  23.374   <1e-83
LotSize      0.542179 0.0326501 16.6057   <1e-49
log_housing = DataFrame(LotSize=log.(housing[:,2]), Price=log.(housing[:,1]))