Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
siber.ellipes->;rmultireg(Y,X,Bbar,A,nu,V)中的错误:不是矩阵_R_Error Handling - Fatal编程技术网

siber.ellipes->;rmultireg(Y,X,Bbar,A,nu,V)中的错误:不是矩阵

siber.ellipes->;rmultireg(Y,X,Bbar,A,nu,V)中的错误:不是矩阵,r,error-handling,R,Error Handling,我对R非常陌生,目前正在尝试创建siber椭圆 我观看了用省略号比较社区成员的potcast:(),一开始相处得很好。每当我使用siber.ellipes函数时,都会出现一个错误: (rmultireg(Y,X,Bbar,A,nu,V)中的错误:不是矩阵) 我不明白为什么。我使用自己的数据以及随脚本提供的zip文件中的示例数据来获取它 我已经在网上研究了错误信息,但没有找到答案 这几乎可能是脚本或数据中的错误,因为我完全按照提供的那样使用它们。我的R版本是3.3.2 这与某种设置有关吗? 原因可

我对R非常陌生,目前正在尝试创建siber椭圆

我观看了用省略号比较社区成员的potcast:(),一开始相处得很好。每当我使用siber.ellipes函数时,都会出现一个错误: (rmultireg(Y,X,Bbar,A,nu,V)中的错误:不是矩阵) 我不明白为什么。我使用自己的数据以及随脚本提供的zip文件中的示例数据来获取它

我已经在网上研究了错误信息,但没有找到答案

这几乎可能是脚本或数据中的错误,因为我完全按照提供的那样使用它们。我的R版本是3.3.2 这与某种设置有关吗? 原因可能是什么

有人能帮我吗:)

谢谢

# this demo generates some random data for M consumers based on N samples and
# constructs a standard ellipse for each based on SEAc and SEA_B

rm(list = ls())

library(siar)

-------------------------------------------------------------------------
# ANDREW - REMOVE THESE LINES WHICH SHOULD BE REDUNDANT
# change this line
setwd("C:/Users/elisabeth/Desktop/R/demo")

#     -----------------------------------------------------------------------------
# now close all currently open windows
graphics.off()

# read in some data
# NB the column names have to be exactly, "group", "x", "y"
mydata <- read.table("example_ellipse_data.txt",sep="\t",header=T)

# make the column names availble for direct calling
attach(mydata)


# now loop through the data and calculate the ellipses
ngroups <- length(unique(group))



# split the isotope data based on group
spx <- split(x,group)
spy <- split(y,group)

# create some empty vectors for recording our metrics
SEA <- numeric(ngroups)
SEAc <- numeric(ngroups)
TA <- numeric(ngroups)

dev.new()
plot(x,y,col=group,type="p")
legend("topright",legend=as.character(paste("Group ",unique(group))),
    pch=19,col=1:length(unique(group)))

for (j in unique(group)){


  # Fit a standard ellipse to the data
  SE <- standard.ellipse(spx[[j]],spy[[j]],steps=1)

  # Extract the estimated SEA and SEAc from this object
  SEA[j] <- SE$SEA
  SEAc[j] <- SE$SEAc

  # plot the standard ellipse with d.f. = 2 (i.e. SEAc)
  # These are plotted here as thick solid lines
  lines(SE$xSEAc,SE$ySEAc,col=j,lty=1,lwd=3)


  # Also, for comparison we can fit and plot the convex hull
  # the convex hull is plotted as dotted thin lines
  #
  # Calculate the convex hull for the jth group's isotope values
  # held in the objects created using split() called spx and spy
  CH <- convexhull(spx[[j]],spy[[j]])

  # Extract the area of the convex hull from this object
  TA[j] <- CH$TA

  # Plot the convex hull
  lines(CH$xcoords,CH$ycoords,lwd=1,lty=3)


}

# print the area metrics to screen for comparison
# NB if you are working with real data rather than simulated then you wont be
# able to calculate the population SEA (pop.SEA)
# If you do this enough times or for enough groups you will easily see the
# bias in SEA as an estimate of pop.SEA as compared to SEAc which is unbiased.
# Both measures are equally variable.
print(cbind(SEA,SEAc,TA))

# So far we have fitted the standard ellipses based on frequentist methods
# and calculated the relevant metrics (SEA and SEAc). Now we turn our attention
# to producing a Bayesian estimate of the standard ellipse and its area SEA_B


reps <- 10^4 # the number of posterior draws to make

# Generate the Bayesian estimates for the SEA for each group using the 
# utility function siber.ellipses
SEA.B <- siber.ellipses(x,y,group,R=reps)
#此演示基于N个样本和
#基于SEAc和SEA_B为每个椭圆构造一个标准椭圆
rm(list=ls())
图书馆(siar)
-------------------------------------------------------------------------
#ANDREW-删除这些应该是多余的线路
#换行
setwd(“C:/Users/elisabeth/Desktop/R/demo”)
#     -----------------------------------------------------------------------------
#现在关闭所有当前打开的窗口
graphics.off()
#读入一些数据
#注意:列名必须精确为“组”、“x”、“y”

mydata使用Jackson的Github站点重新安装SIAR软件包:

library(devtools)
install_github("andrewljackson/siar@v4.2.2", build_vingettes == TRUE)
library(siar)