How to get rid of lmer warning message? - lmer

I have made some changes to the lmer. It works as it should but I could not get rid of the warning message that pops when I run the program. I have added the following options which allows the program run without stopping but with the warning message. I believe it is the check.nobs.vs.rankZ = "warningSmall" part. How could I get rid of this, any suggestions? Thank you.
lmerControl(check.nobs.vs.nlev = "ignore",check.nobs.vs.rankZ =
"warningSmall",check.nlev.gtreq.5 = "ignore",check.nobs.vs.nRE="ignore",
check.rankX = c("ignore"),check.scaleX = "ignore",check.formula.LHS="ignore",
## convergence checking options
check.conv.grad = .makeCC("warning", tol = 1e-3, relTol = NULL),
check.conv.singular = .makeCC(action = "ignore", tol = 1e-4),
check.conv.hess = .makeCC(action = "warning", tol = 1e-6)
Warning Message from R:
Warning message:
In checkZrank(reTrms$Zt, n = n, control, nonSmall = 1e+06) :
number of observations (=300) <= rank(Z) (=300); the random-effects parameters and the
residual variance (or scale parameter) are probably unidentifiable

You should try check.nobs.vs.rankZ="ignore".
lmerControl doesn't need to specify anything other than the non-default options: at a quick glance, these are your non-default values:
lmerControl(check.nobs.vs.nlev = "ignore",check.nobs.vs.rankZ =
"ignore",check.nlev.gtreq.5 = "ignore",check.nobs.vs.nRE="ignore",
check.rankX = c("ignore"),
check.scaleX = "ignore",
check.formula.LHS="ignore",
check.conv.grad = .makeCC("warning", tol = 1e-3, relTol = NULL))
In general I would suggest it's wise to turn off only the specific warnings and errors you know you want to override -- the settings above look like they could get you in trouble.
I haven't checked this since you didn't give a reproducible example ...

Related

Tradingview Pinescript strategy.close() strategy.exit() coemment problem

I'm taring to adjust the strategy on Tradingview to work together with bot using alerts (tradingview).
My problem is that comments have to be the same in strategy.close and strategy.exit
There is any possibility that script will automatically when the condition will be fulfilled for strategy.close to take the comment from strategy.exit ?
Many thanks for help and all the best for You!
/ === STRATEGY - LONG POSITION EXECUTION ===
strategy.entry(id = "Buy", long = true, when = buy[shunt]==1, comment = "ENTER-LONG_BINANCE-FUTURES_ETHBUSD_ETH_30M_9c621" )
strategy.close(id = "Buy", when = direction[shunt]!=direction[shunt+1], comment = "EXIT-LONG_BINANCE-FUTURES_ETHBUSD_ETH_30M_9c21")
// === STRATEGY - SHORT POSITION EXECUTION ===
strategy.entry(id = "Sell", long = false, when = sell[shunt]==1, comment = "ENTER-SHORT_BINANCE-FUTURES_ETHBUSD_ETH_30M_9c621")
strategy.close(id = "Sell", when = direction[shunt]!=direction[shunt+1], comment = "EXIT-SHORT_BINANCE-FUTURES_ETHBUSD_ETH_30M_9c621")
// === STRATEGY RISK MANAGEMENT EXECUTION ===
strategy.exit("Exit Buy", from_entry = "Buy", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset, comment = "EXIT-LONG_BINANCE-FUTURES_ETHBUSD_ETH_30M_9c6c021")
strategy.exit("Exit Sell", from_entry = "Sell", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset, comment = "EXIT-SHORT_BINANCE-FUTURES_ETHBUSD_ETH_30M_9c6c021")
Error
9:23:54 AM — Compilation error. Line 194: Cannot call `strategy.close` with arguments (literal__string, fun_call__operator !=, literal__string); available overloads: strategy.close(literal__string, series__bool) => void;
line 198: Cannot call `strategy.close` with arguments (literal__string, fun_call__operator !=, literal__string); available overloads: strategy.close(literal__string, series__bool) => void
There is any possibility that script will automatically when the condition will be fulfilled for strategy.close to take the comment from strategy.exit ?
Many thanks for help and all the best for You!
Your problem doesn't come from the comments.
You can use the same comments, no problem.
Your error comes from :
when = direction[shunt]!=direction[shunt+1]
in your strategy.close order.
Please update to pinescript v5 and do not use 'when' in your strategy.close, but put your strategy.close in an 'if' block.

networkx output scale problem with matplotlib (re-post)

I'm re-posting this question since I didn't make a good example code in last question.
I'm trying to make a nodes to set in specific location.
But I found out that the output drawing is not... fixed. Let me show you the pic.
So this is the one I make with 10 nodes. worked perfectly as I intended.
Also it has plt.text on the bottom left.
And here's the other picture
As you can see, something is wrong. plt.text is gone, and USA's location is weird. Actually that location is where DEU is located in the first pic. Both pics use same code.
Now, let me show you some of my code.
for spec_df, please download from my gdrive:
https://drive.google.com/drive/folders/11X_i5-pRLGBfQ9vIwQ3hfDU5EWIfR3Uo?usp=sharing
auto_flag = 0
spec_df=pd.read_stata("C:\\"Your_file_loc"\\CombinedHS6_example.dta")
#top_10_list = ["USA","CHN","KOR"] (Try for three nodes)
#or
#auto_flag = 1 (Try for 10 nodes)
df_p = spec_df[['partneriso3','tradevalue']]
df_p = df_p.groupby('partneriso3').sum().reset_index()
df_r = spec_df[['reporteriso3','tradevalue']]
df_r = df_r.groupby('reporteriso3').sum().reset_index()
df_r = df_r.rename(columns={'reporteriso3': 'Nation'})
df_r = df_r.rename(columns={'tradevalue': 'tradevalue_r'})
df_p = df_p.rename(columns={'partneriso3': 'Nation'})
df_s = pd.merge(df_r, df_p, on='Nation', how='outer').fillna(0)
df_s["final"] = df_s['tradevalue'] + df_s['tradevalue_r']
if auto_flag == 1:
df_s = df_s.sort_values(by=['final'], ascending = False).reset_index()
cut = df_s[:10]
else:
cut = df_s[(df_s['Nation'].isin(top_10_list))]
cut['final'] = cut['final'].apply(lambda x: normalize(x, cut['final'].max()))
cut['font_size'] = cut['final'] * 13
cut['final'] = cut['final'] * 1500
top_10_list = list(cut["Nation"])
top10 = spec_df[(spec_df['reporteriso3'].isin(top_10_list))&(spec_df['partneriso3'].isin(top_10_list))]
top10['tradevalue'] = top10['tradevalue'].apply(lambda x: normalize(x, top10['tradevalue'].max()))
top10['tradevalue'] = top10['tradevalue']*10
plt.figure(figsize=(10,10), dpi = 100)
G = nx.from_pandas_edgelist(top10, 'reporteriso3', 'partneriso3', 'tradevalue', create_using= nx.DiGraph())
widths = nx.get_edge_attributes(G,'tradevalue')
pos = {}
pos_cord = [(-0.30779309, -0.26419882), (0.26767895, 0.19524759), (-0.38479095, 0.88179998), (0.33785317, 0.96090914), (0.94090464, 0.40707934), (0.9270665, -0.38403114), (0.41246223, -0.85684049), (-0.32083322, -1.0), (-0.99724456, -0.34947554), (-0.87530367, 0.40950993)]
for t in range(len(top_10_list)):
if top_10_list == "":
continue
else:
pos[top_10_list[t]] = pos_cord[t]
pos_nodes = nudge(pos, 0, 0.12)
nx.draw_networkx_edges(G,pos, width=list(widths.values()), edge_color = '#9ECAE4')
nx.draw_networkx_nodes(G, pos=pos, nodelist = cut['Nation'], node_size= cut['final'], node_color ='#AB89EF', edgecolors ='#000000')
nx.draw_networkx_labels(G,pos_nodes, font_size=15)
plt.text(-1.15,-1.15,s='hs : ')
plt.savefig(location,dpi=300)
Sorry for the crude code. But I want to ask that I'm using fixed coordinates. So nodes are not supposed to move there location. So I think the plt's size is kinda interacting with the contents...? But I don't know how it does that.
Could anyone enlighten me please? This drives me crazy...
Thanks to #Paul Brodersen's comment, I found a way to fix the location.
I just added these codes in my codes.
fig = plt.figure(figsize=(10,10), dpi = 100)
axes = fig.add_axes([0,0,1,1])
axes.set_xlim([-1.3,1.3])
axes.set_ylim([-1.3,1.3])
Thank you for the help again!

ProjError: Error creating Transformer from CRS.:

I am having an issue with Geopandas and PyProj.
I am loading a premade shp file from GeoPandas
borough = gpd.read_file(gpd.datasets.get_path('nybb'))
When trying to do a crs transformation with the following code:
borough = borough.to_crs({'init': 'epsg:4326'})
I get the error:
ProjError: Error creating Transformer from CRS.: (Internal Proj Error: proj_create_operations: SQLite error on SELECT source_crs_auth_name, source_crs_code, target_crs_auth_name, target_crs_code, cov.auth_name, cov.code, cov.table_name, area.south_lat, area.west_lon, area.north_lat, area.east_lon, ss.replacement_auth_name, ss.replacement_code FROM coordinate_operation_view cov JOIN area ON cov.area_of_use_auth_name = area.auth_name AND cov.area_of_use_code = area.code LEFT JOIN supersession ss ON ss.superseded_table_name = cov.table_name AND ss.superseded_auth_name = cov.auth_name AND ss.superseded_code = cov.code AND ss.superseded_table_name = ss.replacement_table_name AND ss.same_source_target_crs = 1 WHERE ((source_crs_auth_name = ? AND source_crs_code = ? AND target_crs_auth_name = ? AND target_crs_code = ?) OR (source_crs_auth_name = ? AND source_crs_code = ? AND target_crs_auth_name = ? AND target_crs_code = ?)) AND cov.deprecated = 0 AND cov.auth_name = ? ORDER BY pseudo_area_from_swne(south_lat, west_lon, north_lat, east_lon) DESC, (CASE WHEN accuracy is NULL THEN 1 ELSE 0 END), accuracy: no such column: ss.same_source_target_crs)
I really am totally clueless about what to do here.
PS: This is my first stackoverflow post, so I apologize in advanced for the poor layout of this post.

How to write new input file after modify flopy package?

I try to load-if exists, update and write new input files in flopy. I try many things but I can't. Here is my code:
rchFile = os.path.join(modflowModel.model_ws, "hydrogeology.rch")
info = modflowModel.get_nrow_ncol_nlay_nper()
if "RCH" in modflowModel.get_package_list():
rchObject = ModflowRch.load(rchFile, modflowModel)
rchData = rchObject.rech
else:
rchData = dict()
for ts in range(info[3]):
rchData[ts] = np.zeros((info[0], info[1]))
for feat in iterator:
for ts in range(info[3]):
currValue = "random value"
rchData[ts][feat["row"]-1, feat["column"]-1] = currValue
rchObject = ModflowRch(modflowModel, nrchop=3, ipakcb=None, rech=rchData, irch=0, extension='rch', unitnumber=None, filenames="hydrogeology.rch")
rchPath = os.path.join(modflowModel.model_ws, 'rch.shp')
rchObject.export(f=rchPath)
# rchObject.write_file()
# modflowModel.add_package(rchObject)
modflowModel.write_input()
modflowModel is and flopy.modflow.Modflow object. Comments at the end of the codes are lines that I try to write updated new inputs but does not work.
What error(s) are you getting exactly when you say it doesnt work? I routinely modify forcing packages with flopy like this:
m = flopy.modflow.Modflow.load()
for kper in range(m.nper):
arr = m.rch.rech[kper].array
arr *= 0.8 # or something
m.rch.rech[kper] = arr
I found my error. modflowModel.write_input() works very well. Problem occures while loading model object Modflow.load(...). Now I load model whereever I need. Because if I load it another py etc., there might me model_ws confusion.

I am facing End of file reached error

I am newbie to python and was trying following code
class Arm(object):
def __init__(self, SNo, ActivityDate, RequesterTeam, RequesterSignumId, RequesterEmailId,Circle,Customer,Technology,WOType,ProblemTitle,ActivityTypeorEqType,SiteID,BSCFACID,EngineerName,EngineerSignum,DetailDescriptionOfActivityToBePerformed,TimelineforActivityCompletion,WOIDbyWFM ):
self.SNo= SNo
self.ActivityDate=ActivityDate
self.RequesterTeam=RequesterTeam
self.RequesterSignumId=RequesterSignumId
self.RequesterEmailId=RequesterEmailId
self.Circle=Circle
self.Customer=Customer
self.Technology=Technology
self.WOType=WOType
self.ProblemTitle=ProblemTitle
self.ActivityTypeorEqType=ActivityTypeorEqType
self.SiteID=SiteID
self.BSCFACID=BSCFACID
self.EngineerName=EngineerName
self.EngineerSignum=EngineerSignum
self.DetailDescriptionOfActivityToBePerformed=DetailDescriptionOfActivityToBePerformed
self.TimelineforActivityCompletion=TimelineforActivityCompletion
self.WOIDbyWFM=WOIDbyWFM
def __str__(self):
return("Arm object:\n"
"SNo = {0}\n"
"ActivityDate = {1}\n"
"RequesterTeam = {2}\n"
"RequesterSignumId = {3}\n"
"RequesterEmailId = {4}\n"
"Circle = {5}\n"
"Customer = {6}\n"
"Technology = {7}\n"
"WOType = {8}\n"
"ProblemTitle = {9}\n"
"ActivityTypeorEqType = {10}\n"
"SiteID = {11}\n"
"BSCFACID = {12}\n"
"EngineerName = {13}\n"
"EngineerSignum = {14}\n"
"DetailDescriptionOfActivityToBePerformed = {15}\n"
"TimelineforActivityCompletion= {16}\n"
"WOIDbyWFM = {17}\n"
.format(self.SNo,
self.ActivityDate,
self.RequesterTeam,
self.RequesterSignumId,
self.RequesterEmailId,
self.Circle,
self.Customer,
self.Technology,
self.WOType,
self.ProblemTitle,
self.ActivityTypeorEqType,
self.SiteID,
self.BSCFACID,
self.EngineerName,
self.EngineerSignum,
self.DetailDescriptionOfActivityToBePerformed,
self.TimelineforActivityCompletion,
self.WOIDbyWFM)
I am getting
File
"C:\Users\OpenSource\eclipse-workspace\PythonWorkSpace\DataHiding\src\Hiding.py", line 26 ^ SyntaxError:unexpected EOF while parsing error
while running the code. please suggest me where i am making errors.
You should have "WOIDbyWFM = {17}\n"..format(self.SNo, .......
You are missing a closing right parentheses at the end of your return statement.
Please use the PyCharm editor and it will show you all errors like eclipse does and then you can correctly indent your code to make it bug free.

Resources