- 已编辑
大家好
最近在嘗試非線性回歸
require(ggplot2)
warnings('off')
x <- rep(c(1, 2, 3, 5, 7, 10),each=4)
y <-c( 105,
97,
104,
106,
136,
161,
151,
153,
173,
179,
174,
174,
195,
182,
201,
172,
207,
194,
206,
213,
218,
193,
235,
229
)
ds <- data.frame(day = x, data = y)
model <- nls(
# y ~ b0 * (1- exp(-b1 * x)),
y ~ b0 * x / (b1 + x),
data = ds,
start = list(b0 = 200,
b1 = 2),
trace = T
)
雖然以上程式可以執行,但卻會跑出以下警告
Warning messages:
1: In min(x) : min 中沒有無漏失的引數; 回傳 Inf
2: In max(x) : max 中沒有無漏失的引數;回傳 -Inf
這個警告訊息應該是在設定nls起始值的時候沒有設定的很好的關係?加了warnings('off')
也沒用
最後在knitr成pdf的時候會失敗
想知道這樣的狀況有沒有可以knit的方法?
附上yaml跟header檔
感謝大家
title: "Nonlinear"
author: You Jia Sun
date: "最近一次編輯時間 `r format(Sys.time(), '%Y年%m月%d日')`"
geometry: margin=1.18in
documentclass: ctexart
output:
bookdown::pdf_book:
number_sections: yes
pandoc_args: --listings
toc: yes
fig_crop: no
base_format: rmarkdown::pdf_document
latex_engine: xelatex
citation_package: natbib
dev: "cairo_pdf"
template: null
extra_dependencies:
sourcecodepro:
- scale=0.85
sourceserifpro:
- rmdefault
sourcesanspro:
- sfdefault
awesomebox:
quote_footer: ["\\hspace*{\\fill} ", ""]
geometry:
- top=30mm
- left=20mm
includes:
in_header: header.tex
biblio-style: plainnat #apalike
natbiboptions: "authoryear,round"
link-citations: yes
colorlinks: yes
classoption: "UTF8,a4paper,fontset=adobe,zihao=false"
\usepackage{xeCJK}
\usepackage{listings}
\setCJKmainfont{微軟正黑體}
\lstset{
breaklines=true
}