gpt4 book ai didi

r - siber.ellipses-> rmultireg(Y,X,Bbar,A,nu,V): not a matrix中的错误

转载 作者:行者123 更新时间:2023-12-03 08:50:31 25 4
gpt4 key购买 nike

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

我观看了使用省略号比较社区成员的potcast :( http://www.tcd.ie/Zoology/research/research/theoretical/Rpodcasts.php#siber),开始时相处得很好。每当我使用siber.ellipses的功能时,都会收到错误消息:
(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)

rmultireg(Y,X,Bbar,A,nu,V)中的错误:不是矩阵

最佳答案

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

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

关于r - siber.ellipses-> rmultireg(Y,X,Bbar,A,nu,V): not a matrix中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42207681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com