2017-02-13 12 views
0

Я очень новичок в R и в настоящее время пытаюсь создать эллипсы.siber.ellipses -> Ошибка в rmultireg (Y, X, Bbar, A, nu, V): не матрица

Я смотрел кастрюлю Используя эллипсы, чтобы сравнить членов сообщества :(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 Это связано с некоторыми настройками? В чем может быть причина?

Может кто-то пожалуйста Helpe меня :)

благодаря

# 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, просветляющего, A, ню, V): не матрица

ответ

0

Переустановка СИАР пакет с использованием Jackson's Github site:

library(devtools) 
install_github("andrewljackson/[email protected]", build_vingettes == TRUE) 
library(siar)