rm(list=ls(all=TRUE))
data <- read.csv("con.csv", header=TRUE, sep = ",")
x <- data$X0
n = length(x); T1 <- 1
f <- function(a,b) {
L <- (n*log(a))+(n*a*log(T1))+(n*a*log(b))-(n*log((T1^a)-(b^a)))- ((a+1)*sum(log(b+x)))
return(-L)
}
ML <- nlm(f, c(0.01,0.17))
结果 f(x,...)出错:缺少参数“x”,没有默认值 帮助我找出解决问题的错误和解决方案
答案 0 :(得分:2)
传递给函数csv
的参数必须是单个向量。这是正确的定义:
import pandas as pd
import boto3
bucket = "yourbucket"
file_name = "your_file.csv"
s3 = boto3.client('s3')
# 's3' is a key word. create connection to S3 using default config and all buckets within S3
obj = s3.get_object(Bucket= bucket, Key= file_name)
# get object and file (key) from bucket
initial_df = pd.read_csv(obj['Body']) # 'Body' is a key word
和一个工作示例:
f
结果是:
f <- function(pars) {
L <- (n*log(pars[1]))+(n*pars[1]*log(T1))+(n*pars[1]*log(pars[2]))-
(n*log((T1^pars[1])-(pars[2]^pars[1])))- ((pars[1]+1)*sum(log(pars[2]+x)))
return(-L)
}