全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
14411 15
2011-07-06
boston数据是spdep包中的一个数据集,使用命令如何查看?当然,原始数据可以从http://lib.stat.cmu.edu/datasets/boston_corrected.txt下载
我用过如下命令不可行:
data("boston",package="spdep")
> bonston
错误: 找不到对象'bonston'

还有看到如下命令不知道什么意思?

data(boston)
attach (boston.c)   ##这里boston.c是什么含义?还看到过boston.soi,不知道是啥

..........中间是一些读入数据命令

detach(boston.c)   



还有一个问题:
lm()函数是线性回归的,可以返回一些值:

coefficientsa named vector of coefficients
residualsthe residuals, that is response minus fitted values.
fitted.valuesthe fitted mean values.

这里的fitted.values是指什么意思?我下面理解对吗

如做y=bx+delta回归,运行得到b-bar
fitted.values是等于b-bar*x吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2011-7-6 18:50:18
老兄你没仔细看spdep.pdf
boston Corrected Boston Housing Data
就是含:

boston.c : data frame has 506 rows and 20 columns
  boston.utm : a matrix of tract point coordinates projected to UTM zone 19
                         506 x 2 matrix
  boston.soi : a sphere of influence neighbours list
                        nb2listw(boston.soi)
> data(boston)
> boston.c
> boston.utm
> nb2listw(boston.soi)

###########
x=c(1,2,3,4,5,6,7,8,9,10);
y=c(6,7,8,4,9,11,12,14,15,19);
lm=lm(y~x)
lm
#(Intercept)            x  
#      2.867        1.388  
lm$fitted.values
#        1         2         3         4         5         6         7         8         9        10
# 4.254545  5.642424  7.030303  8.418182  9.806061 11.193939 12.581818 13.969697 15.357576 16.745455
lm$coefficients[2]*x+lm$coefficients[1]
#[1]  4.254545  5.642424  7.030303  8.418182  9.806061 11.193939 12.581818 13.969697 15.357576 16.745455
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-6 19:04:54
Approximate profile-likelihood estimator (APLE)
这句话翻译成中文是什么意思?profile likelihood estimation 的思想是什么?谢谢!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-6 22:16:50
epoh老师,呵呵,没有仔细看过
明白了
第二个问题我开始理解的应该也正确,我没有加入常数项
通过您数据演示,完全明白了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-7 08:55:29
Approximate profile-likelihood estimator (APLE)
抱歉这个问题
还真没用心研究比较过!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-7 10:26:45
epoh老师,您能对下面问题发表下意见不,哈哈
R包spdep中的函数nbdists()可以根据经纬度LON,LAT计算距离。
看函数描述,
Given a list of spatial neighbour links (a neighbours list of object type nb), the function returns the Euclidean distances along the links in a list of the same form as the neighbours list. If longlat = TRUE, Great Circle distances are used.
函数可以计算两类距离:一种是欧氏距离-Euclidean distance,另一种是Great circle 距离。
我找了网上相关资料,提到了:
设第一点A的经 纬度为(LonA, LatA),第二点B的经纬度为(LonB, LatB),按照0度经线的基准,东经取经度的正值(Longitude),西经取经度负值(-Longitude),北纬取90-纬度值(90- Latitude),南纬取90+纬度值(90+Latitude),则经过上述处理过后的两点被计为(MLonA, MLatA)和(MLonB, MLatB)。那么根据三角推导,可以得到计算两点距离的如下公式:
C = sin(MLatA)*sin(MLatB)*cos(MLonA-MLonB) + cos(MLatA)*cos(MLatB)
Distance = R*Arccos(C)*Pi/180
这里,R和Distance单位是相同,如果是采用6371.004千米作为半径,那么Distance就是千米为单位,如果要使用其他单位,比如mile,还需要做单位换算,1千米=0.621371192mile
如果仅对经度作正负的处理,而不对纬度作90-Latitude(假设都是北半球,南半球只有澳洲具有应用意义)的处理,那么公式将是:
C = sin(LatA)*sin(LatB) + cos(LatA)*cos(LatB)*cos(MLonA-MLonB)
Distance = R*Arccos(C)*Pi/180


上面提到方法是计算Great Circle 距离的
中国是东经、北纬,那我计算欧氏距离的时候需要和计算Great Circle距离一样吗?把北纬取90-LAT?
看了R里面计算公式,没有看懂。没有弄明白怎么把经纬度转化为计算欧氏距离的X1,Y2,X2,Y2两点坐标。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群