我正在尝试使用Python statsmodels线性混合效果模型来拟合具有两个随机截距的模型,例如两个组.我无法弄清楚如何初始化模型,以便我可以做到这一点.
这是一个例子.我的数据如下所示(取自此处):
subject gender scenario attitude frequency
F1 F 1 pol 213.3
F1 F 1 inf 204.5
F1 F 2 pol 285.1
F1 F 2 inf 259.7
F1 F 3 pol 203.9
F1 F 3 inf 286.9
F1 F 4 pol 250.8
F1 F 4 inf 276.8
Run Code Online (Sandbox Code Playgroud)
我想制作一个具有两个随机效果的线性混合效果模型 - 一个用于主题组,一个用于场景组.我想这样做:
import statsmodels.api as sm
model = sm.MixedLM.from_formula("frequency ~ attitude + gender", data, groups=data[['subject', 'scenario']])
result = model.fit()
print result.summary()
Run Code Online (Sandbox Code Playgroud)
我一直收到这个错误:
LinAlgError: Singular matrix
Run Code Online (Sandbox Code Playgroud)
它在R中工作正常.当我lme4在R中使用基于公式的渲染时,它很适合:
politeness.model …Run Code Online (Sandbox Code Playgroud) 我正在我的 web 应用程序上实现 FB 登录www.glifft.com但我似乎无法正确重定向。登录后的重定向应为https://www.glifft.com/myglift。我在 Jinja2 模板中使用 Flask 中的 url_for() 函数来生成此 URL。但我似乎无法用前面的https生成。它始终生成为 http。
这是我的 JavaScript:
function getuserDetails(accessToken) {
FB.api('/me',{ locale: 'en_US', fields: 'name, email' }, function(response) {
$.ajax({
url: "/register",
type: "POST",
data: {
name: response.name,
email: response.email,
login_provider : "Facebook",
access_token: accessToken
},
success: function(response) {
location.href = "{{ url_for('myglifft', _external=True) }}";
console.log(location.href)
},
error: function(response) {
alert("Please check your facebook privacy settings.");
console.log(response)
}
});
});
Run Code Online (Sandbox Code Playgroud)
location.href 函数不断解析为http://www.glift.com。即使在我的配置中我有
PREFERRED_URL_SCHEME = 'https'
Run Code Online (Sandbox Code Playgroud)
我在 …
I'm trying to do unit testing of my Flask web app. I'm use a pattern I saw in a Udemy class on Flask and a pattern similar to the Flask Mega-Tutorial online (http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-unit-testing). The problem I'm having is that the test does not actual create it's own database -- rather it uses the production database and messes it up.
Here's what tests.py script looks like:
import os,sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
basedir = os.path.abspath(os.path.dirname(__file__))
import unittest
from myapp import app, …Run Code Online (Sandbox Code Playgroud)