简体   繁体   English

R:多元线性回归误差

[英]R: Multiple Linear Regression error

I am having hard times running the lm() function and understanding the error. 我在运行lm()函数并理解错误时遇到了困难。

So, my script is this: 所以,我的脚本是这样的:

#! /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)

And the console output is this: 控制台输出是这样的:

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

I ve read some similar questions here and there but i still can't figure out what i am doing wrong. 我到处都读过一些类似的问题,但我仍然不知道自己在做什么错。 I need temperature as my response y variable to be calculated by the independent x1,x2 altitude and sea.distance variables. 我需要temperature作为我的响应y变量,由独立的x1,x2 altitudesea.distance变量来计算。

Any help will be appreciated, just try to be specific. 任何帮助将不胜感激,只是尝试具体。 Thanks in advance 提前致谢

R uses . R使用. as the decimal separator. 作为小数点分隔符。 Your data uses , and R interprets the data as characters, which are made factor variables by default. 您的数据使用,并且R将数据解释为字符,默认情况下将其作为因子变量。 Use dec="," to tell read.table that the data is numeric with , as the decimal separator. 使用dec=","告诉read.table数据为数字,以用作小数点分隔符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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