[英]R: Multiple Linear Regression error
我在运行lm()
函数并理解错误时遇到了困难。
所以,我的脚本是这样的:
#! /usr/bin/env/ Rscript
meteodata <- read.table("/path/to/dataset.txt", header=T)
meteodata
summary(meteodata)
plot(meteodata)
lmodel <- lm(temperature~altitude+sea.distance, data=meteodata)
控制台输出是这样的:
temperature station.id latitude longtitude sea.distance altitude
1 20,1 S1 0,5 0,5 0,5 0
2 20,5 S1 0,5 0,5 0,5 0
3 19,3 S1 0,5 0,5 0,5 0
4 18,6 S1 0,5 0,5 0,5 0
5 21,5 S1 0,5 0,5 0,5 0
6 17,1 S2 3,5 2,5 1,5 200
7 18,3 S2 3,5 2,5 1,5 200
8 16,8 S2 3,5 2,5 1,5 200
9 17,5 S2 3,5 2,5 1,5 200
10 16,4 S2 3,5 2,5 1,5 200
11 18,4 S3 2,5 3,5 0,5 100
12 19,1 S3 2,5 3,5 0,5 100
13 18,9 S3 2,5 3,5 0,5 100
14 17,8 S3 2,5 3,5 0,5 100
15 17,6 S3 2,5 3,5 0,5 100
16 15,1 S4 4 0 4 400
17 15,5 S4 4 0 4 400
18 15,0 S4 4 0 4 400
19 14,9 S4 4 0 4 400
20 15,8 S4 4 0 4 400
temperature station.id latitude longtitude sea.distance altitude
14,9 : 1 S1:5 0,5:5 0 :5 0,5:10 Min. : 0
15,0 : 1 S2:5 2,5:5 0,5:5 1,5: 5 1st Qu.: 75
15,1 : 1 S3:5 3,5:5 2,5:5 4 : 5 Median :150
15,5 : 1 S4:5 4 :5 3,5:5 Mean :175
15,8 : 1 3rd Qu.:250
16,4 : 1 Max. :400
(Other):14
Warning messages:
1: In model.response(mf, "numeric") :
using type = "numeric" with a factor response will be ignored
2: In Ops.factor(y, z$residuals) : - not meaningful for factors
我到处都读过一些类似的问题,但我仍然不知道自己在做什么错。 我需要temperature
作为我的响应y变量,由独立的x1,x2 altitude
和sea.distance
变量来计算。
任何帮助将不胜感激,只是尝试具体。 提前致谢
R使用.
作为小数点分隔符。 您的数据使用,
并且R将数据解释为字符,默认情况下将其作为因子变量。 使用dec=","
告诉read.table
数据为数字,
以用作小数点分隔符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.