楼主: ywh19860616
13448 15

[问答] 如何使用命令查看boston数据 [推广有奖]

学术权威

32%

还不是VIP/贵宾

-

威望
0
论坛币
870 个
通用积分
3477.1298
学术水平
854 点
热心指数
991 点
信用等级
637 点
经验
116346 点
帖子
3976
精华
0
在线时间
7729 小时
注册时间
2009-9-3
最后登录
2023-12-9

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
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吗?
二维码

扫码加我 拉你入群

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

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

关键词:Boston Bosto 如何使用 Bost sto 数据 命令 Boston

一份耕耘,一份收获。
沙发
epoh 发表于 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
已有 3 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
ywh19860616 + 5 + 5 + 5 谢谢epoh老师,第一个问题字母输错了,明白了
zhangtao + 5 + 5 + 5 好的意见建议
yahoocom + 20 热心帮助其他会员

总评分: 论坛币 + 20  学术水平 + 10  热心指数 + 10  信用等级 + 10   查看全部评分

使用道具

藤椅
zhangtao 发表于 2011-7-6 19:04:54 |只看作者 |坛友微信交流群
Approximate profile-likelihood estimator (APLE)
这句话翻译成中文是什么意思?profile likelihood estimation 的思想是什么?谢谢!
数学好就是要天天学

使用道具

板凳
ywh19860616 发表于 2011-7-6 22:16:50 |只看作者 |坛友微信交流群
epoh老师,呵呵,没有仔细看过
明白了
第二个问题我开始理解的应该也正确,我没有加入常数项
通过您数据演示,完全明白了
一份耕耘,一份收获。

使用道具

报纸
epoh 发表于 2011-7-7 08:55:29 |只看作者 |坛友微信交流群
Approximate profile-likelihood estimator (APLE)
抱歉这个问题
还真没用心研究比较过!

使用道具

地板
ywh19860616 发表于 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两点坐标。
一份耕耘,一份收获。

使用道具

7
epoh 发表于 2011-7-8 17:03:43 |只看作者 |坛友微信交流群
from London
to Kuala Lumpur:
latL = 51.5188;
lonL = -0.1300;
latK = 2.9519;
lonK = 101.8200;


###########package package "SpatialEpi"
coord <- data.frame(rbind(c(-0.1300,51.5188),c(101.8200,2.9519)))
xy=latlong2grid(coord)
xy
#           x         y
#1  -11.30656 5725.4371
#2 8855.64857  328.0534

xy/6371
#             x          y
#1 -0.001774692 0.89867166
#2  1.389993498 0.05149167

#######################################
toradians <- atan(1)/45
radiusearth <- 0.5*(6378.2+6356.7)
sine51 <- sin( 51.5*toradians )
input=coord
output <- data.frame(cbind(
x=(input[,1]*toradians)*radiusearth*sine51,
y=(input[,2]*toradians)*radiusearth ))
output
#           x         y
#1  -11.30656 5725.4371
#2 8855.64857  328.0534

output/6371
#             x          y
#1 -0.001774692 0.89867166
#2  1.389993498 0.05149167
已有 2 人评分学术水平 热心指数 信用等级 收起 理由
zhangtao + 5 + 5 + 5 好的意见建议
ywh19860616 + 5 + 5 + 5 epoh老师,谢谢您了,找了好久,没有看到这个包,呵呵。还向您请教一个问题,谢谢

总评分: 学术水平 + 10  热心指数 + 10  信用等级 + 10   查看全部评分

使用道具

8
ywh19860616 发表于 2011-7-8 21:58:52 |只看作者 |坛友微信交流群
epoh老师,在一般R中,这两个有何区别?
Usage
## S3 method for class 'formula'
glmboost(formula, data = list(), weights = NULL,
          na.action = na.pass, contrasts.arg = NULL,
          center = FALSE, control = boost_control(), ...)
## S3 method for class 'matrix'
glmboost(x, y, center = FALSE, control = boost_control(), ...)


在以前一般线性回归函数lm()中,我以为可以写成这两种形式的:
第一种:
form1=y~x
lm(form1,.....)
第二种
lm(x,y,....)
不过我看了lm函数,只能第一种。

因此,我不知道上面的class 'formula'和class 'matrix'有什么区别
我用同一个y和x试了,结果差别很大

您抽空时帮我看看,谢谢您了
一份耕耘,一份收获。

使用道具

9
epoh 发表于 2011-7-9 09:08:00 |只看作者 |坛友微信交流群
x=c(1,2,3,4,5,6,7,8,9,10)
y=c(6,7,8,4,9,11,12,14,15,19)
############formula
lm=lm(y~x)
lm
#Coefficients:
#(Intercept)            x  
#      2.867        1.388  

##########matrix
x1=cbind(1,x)
lm.fit(x1,y)
lm.fit$$coefficients
#                x
#2.866667 1.387879
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
ywh19860616 + 5 + 5 + 5 epoh老师,谢谢您。glmboost函数和这个不太一样,我运行过结果,完全不一

总评分: 学术水平 + 5  热心指数 + 5  信用等级 + 5   查看全部评分

使用道具

10
ywh19860616 发表于 2011-7-9 11:20:01 |只看作者 |坛友微信交流群
epoh老师,谢谢您。
glmboost函数和这个不太一样,我运行过结果,完全不一样。我再仔细研究下
一份耕耘,一份收获。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 22:16