簡體   English   中英

R:多元線性回歸誤差

[英]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 altitudesea.distance變量來計算。

任何幫助將不勝感激,只是嘗試具體。 提前致謝

R使用. 作為小數點分隔符。 您的數據使用,並且R將數據解釋為字符,默認情況下將其作為因子變量。 使用dec=","告訴read.table數據為數字,以用作小數點分隔符。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM